﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="send-register.aspx.cs" Inherits="famails.BackEnd.page.send_register" MasterPageFile="~/Master.Master" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <style type="text/css">
        
    </style>

    <script type="text/javascript">

        function checkChange() {

            var startDate = document.getElementById("txtStartDate1");
            var sendNow = document.getElementById("ContentPlaceHolder1_chkNow");
            var sendWithTime = document.getElementById("ContentPlaceHolder1_chkSet");
            if (sendNow.checked == true) {
                sendWithTime.checked = false;
                startDate.style.visibility = "hidden";
            } else {
                sendWithTime.checked = true;
                startDate.style.visibility = "visible";
            }
        }
        function checkChange2() {

            var startDate = document.getElementById("txtStartDate1");
            var sendNow = document.getElementById("ContentPlaceHolder1_chkNow");
            var sendWithTime = document.getElementById("ContentPlaceHolder1_chkSet");
            if (sendWithTime.checked == true) {
                sendNow.checked = false;
                startDate.style.visibility = "visible";
            }
            else {
                sendNow.checked = true;
                startDate.style.visibility = "hidden";
            }
        }
        function templateChange() {
            var contentId = $('select#<%=drlContent.ClientID%> option:selected').val();
            var Content = document.getElementById("ContentPlaceHolder1_drlContent");
            var subject = Content.options[Content.selectedIndex].text;
            document.getElementById("ContentPlaceHolder1_txtSubject").value = subject;
            $.ajax({
                type: "POST",
                url: "send-register.aspx/getContentTemplate",
                data: '{contentId: "' + contentId + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: templateChangeSuccess,
                failure: function (response) {
                    alert("Không tồn tại mẫu này !");
                }
            });
        }
         
        function templateChangeSuccess(response) {

            CKEDITOR.instances.ContentPlaceHolder1_txtBody.setData(response.d);
            var contentId = $('select#<%=drlContent.ClientID%> option:selected').val();
            var hiddenContentID = document.getElementById("ContentPlaceHolder1_hdfContentID");
            hiddenContentID.value = contentId;

        }
        function signatureChange() {
            var SignId = $('select#<%=drlSign.ClientID%> option:selected').val();
          $.ajax({
              type: "POST",
              url: "send-register.aspx/getSign",
              data: '{SignId: "' + SignId + '" }',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: signatureChangeSuccess,
              failure: function (response) {
                  alert("Chữ ký không tồn tại!");
              }
          });
      }
      function signatureChangeSuccess(response) {
          var dataResponse = response.d;
          var currentData = CKEDITOR.instances.ContentPlaceHolder1_txtBody.getData();
          var displayData = currentData + "</br>" + dataResponse;
          CKEDITOR.instances.ContentPlaceHolder1_txtBody.setData(displayData);
      }
      function insertHello() {
          var firtHello = document.getElementById("ContentPlaceHolder1_txtWelcome");
          var lastHello = document.getElementById("ContentPlaceHolder1_txtAfterWelcome");
          var customerName = document.getElementById("ContentPlaceHolder1_rdoCustomerName");
          var Wellcome = firtHello.value + " " + "[khachhang]" + " " + lastHello.value;
          if (customerName.checked == true) {
              Wellcome;
          }
          else {
              Wellcome = firtHello.value + " " + "[email]" + " " + lastHello.value;
              alert(Wellcome);
          }
          var currentData = CKEDITOR.instances.ContentPlaceHolder1_txtBody.getData();
          var displayData = Wellcome + "</br>" + currentData;
          CKEDITOR.instances.ContentPlaceHolder1_txtBody.setData(displayData);
      }
      function checkSpam() {

          var _title = document.getElementById("ContentPlaceHolder1_txtSubject").value;
          var _content = CKEDITOR.instances.ContentPlaceHolder1_txtBody.getData();
          var encodedHTML = escape(_content);
          $.ajax({
              type: "POST",
              url: "send-register.aspx/Spam",
              data: "{title:'" + _title + "',content:'" + encodedHTML + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: spamCheckSuccess,
              failure: function (response) {
                  alert("Chữ ký không tồn tại!");
              }
          });
      }

      function spamCheckSuccess(response) {
          var dataResponse = response.d;
          if (dataResponse != null) {
              var check = document.getElementById("ContentPlaceHolder1_lblDataRespone");
              check.innerHTML = dataResponse;
              //$("#dialog-form").dialog("open");
              $('#window').jqxWindow('open');
          }
      }
      $(function () {
          checkChange();
          var name = $("#name"),
          email = $("#email"),
          password = $("#password"),
          allFields = $([]).add(name).add(email).add(password),
          tips = $(".validateTips");
          function updateTips(t) {
              tips
              .text(t)
             .addClass("ui-state-highlight");
              setTimeout(function () {
                  tips.removeClass("ui-state-highlight", 1500);
              }, 500);
          }

          var basicDemo = (function () {
              //Adding event listeners
              function _addEventListeners() {

                  $('#btnCheck').click(function () {
                      //loadtree();
                      var x = ($(window).width() - $("#window").jqxWindow('width')) / 2 + $(window).scrollLeft();
                      var y = ($(window).height() - $("#window").jqxWindow('height')) / 2 + $(window).scrollTop();
                      $("#window").jqxWindow({ position: { x: x, y: y } });
                      $('#window').jqxWindow('open');
                  });
                  $('#hideWindowButton').click(function () {
                      $('#window').jqxWindow('close');
                  });
              }; 
              //Creating all page elements which are jqxWidgets
              function _createElements() {

                  //$('#resizeCheckBox').jqxCheckBox({ width: '185px', checked: true });
                  //$('#dragCheckBox').jqxCheckBox({ width: '185px', checked: true });
              };
              //Creating the demo window
              function _createWindow() {
                  $('#window').jqxWindow({
                      showCollapseButton: true, maxHeight: 500, maxWidth: 800, minHeight: 200, minWidth: 200, height: 300, width: 800,
                      initContent: function () {
                          //$('#tab').jqxTabs({ height: '100%', width: '100%' });
                          $('#window').jqxWindow('focus');
                          $('#window').jqxWindow('close');
                      }
                  });
              };
              return {
                  config: {
                      dragArea: null
                  },
                  init: function () {
                      //Creating all jqxWindgets except the window
                      _createElements();
                      //Attaching event listeners
                      _addEventListeners();
                      //Adding jqxWindow
                      _createWindow();
                  }
              };
          }());
          //Initializing the demo
          basicDemo.init();
          $("#txtStartDate1").jqxDateTimeInput({
              width: '170px', height: '34px',
              formatString: "dd/MM/yyyy HH:mm"
          });
          if ($('#ContentPlaceHolder1_txtStartDate_v').val() != undefined)
              $('#txtStartDate1').jqxDateTimeInput('val', $('#ContentPlaceHolder1_txtStartDate_v').val());
          else $('#txtStartDate1').jqxDateTimeInput('val', new Date($.now()));

          $('#txtStartDate1').on('change', function (event) {
              $('#ContentPlaceHolder1_txtStartDate_v').val($("#txtStartDate1").val());
              alert($('#ContentPlaceHolder1_txtStartDate_v').val());
          });/**/

          //$('.form_datetime').datetimepicker({
          //    //language:  'fr',
          //    weekStart: 1,
          //    todayBtn: 1,
          //    autoclose: 1,
          //    todayHighlight: 1,
          //    startView: 2,
          //    forceParse: 0,
          //    showMeridian: 1
          //    , format:'dd/MM/yyyy HH:mm'
          //});
          //$('.form_datetime').datetimepicker()
          //.on('changeDate', function(e){
          //    $('#ContentPlaceHolder1_txtStartDate_v').val($(".form_datetime").val());
          //    alert($('#ContentPlaceHolder1_txtStartDate_v').val());
          //});
      });
    </script>

    <div id="window">
        <div id="windowHeader">
            <span>Thống kê nội dung các quy tắc vi phạm của mẫu email dạng HTML chi tiết như bên dưới:
            </span>
        </div>
        <div style="overflow: hidden;" id="windowContent">

            <fieldset>
                <asp:Label ID="lblDataRespone" runat="server" Text="Data"></asp:Label>
            </fieldset>
        </div>
    </div>

    <div style="width: 100%; padding: 10px;">
        <!--start content 01-->
        <div style="border: 1px solid #333; margin-bottom: 10px;">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold; position: relative;">
                Thiết lập thời gian gửi
            </div>
            <!-- end content-module-heading -->
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 10px;">
                <asp:Panel Visible="false" ID="pnError" runat="server">
                    <div class="error-box round">
                        <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
                <asp:Panel Visible="false" ID="pnSuccess" runat="server">
                    <div class="confirmation-box round">
                        <asp:Label ID="lblSuccess" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
            </div>
            <div class="content-module-main cf">
                <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                    <fieldset>
                        <label for="simple-input" style="font-weight: bolder; text-transform: none">
                            Chọn email gửi đi</label>
                        <asp:DropDownList ID="drlMailConfig" CssClass="form-control" Style="border: 1px solid #333; border-radius: 0px;" runat="server">
                        </asp:DropDownList>
                    </fieldset>
                </div>
                <!-- end half-size-column -->
                <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                    <fieldset>
                        <asp:ScriptManager ID="ScriptManager1" runat="server">
                        </asp:ScriptManager>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <label for="full-width-input" style="font-weight: bolder; text-transform: none">
                                    Chọn nhóm nhận</label>
                                <asp:DropDownList ID="drlMailGroup" Style="margin-bottom: 5px; border: 1px solid #333; border-radius: 0px;" CssClass="form-control" runat="server"
                                    AutoPostBack="True" OnSelectedIndexChanged="drlMailGroup_SelectedIndexChanged">
                                </asp:DropDownList>
                                <em style="color: #333;">
                                    <asp:HiddenField ID="hdfCountCustomer" runat="server" />
                                    <asp:Label ID="lblCountCustomer" runat="server" Text=""></asp:Label>
                                </em>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <%-- <p>
                                        <label for="simple-input">
                                            Gửi từng phần </label>
                                         <label for="selected-checkbox" class="alt-label">
                                         <asp:CheckBox ID="chkPartSend" runat="server" /> Chấp nhận</label>                                          
                                        <em>Tùy chọn này sẽ chấp nhận đây là chiến dịch gửi mail từng phần !</em>
                                        <em>Nhóm mail đã chọn có 
                                            <asp:HyperLink ID="hplCountPartSend" runat="server" Target="_blank"></asp:HyperLink>
                                             được gửi đi !</em>
                                        <em>Bạn có thể 
                                            <asp:LinkButton ID="lbtResetPartSend" 
                                            OnClientClick="return confirmDelete('Bạn có chắc rằng sẽ hủy bỏ chiến dịch gửi mail từng phần với nhóm mail này không  ?')"  
                                            runat="server" onclick="lbtResetPartSend_Click"> reset </asp:LinkButton> chiến dịch gửi từng phần với nhóm này</em>
                                    </p>--%>
                    </fieldset>
                </div>
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 10px;">
                    <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="background: #333; color: #fff; padding: 10px 20px 0px;">
                        <div class="col-md-2 col-lg-2 col-sm-12 col-xs-12" style="padding: 0px; padding-top: 5px;">
                            Chọn thời gian gửi
                        </div>
                        <div class="col-md-3 col-lg-3 col-sm-4 col-xs-6" style="padding: 0px; padding-top: 5px;">
                            <asp:CheckBox ID="chkNow" Checked="True" runat="server" onclick="checkChange()" />
                            Gửi ngay
                        </div>
                        <div class="col-md-3 col-lg-3 col-sm-4 col-xs-6" style="padding: 0px; padding-top: 5px; padding-left: 5px;">
                            <asp:CheckBox ID="chkSet" runat="server" onclick="checkChange2()" />
                            Gửi hẹn giờ
                        </div>
                        <div class="col-md-4 col-lg-4 col-xs-12 col-sm-4" style="padding: 0px;height:46px;">
                            <%--<asp:TextBox ID="txtStartDate" CssClass="round default-width-input" runat="server" type="datetime-local"
                                BackColor="#CCFFFF" style="visibility: hidden;background:#fff;border-radius:0px;color:#333;width:200px;">
                                </asp:TextBox>--%>
                           <%-- <div class="form-group">
                                <div id="txtStartDate1" style="border:1px solid #333;border-radius:0px;" class="input-group date form_datetime" data-date-format="dd/mm/yyyy - HH:ii P" data-link-field="dtp_input1">
                                    <input class="form-control" style="border-radius:0px;border:1px solid #333;" size="16" type="text" value="" readonly>
					                <span class="input-group-addon" style="border-radius:0px;border:1px solid #333;"><span class="glyphicon glyphicon-th"></span></span>
                                </div>--%><div id="txtStartDate1" ></div>
				                <asp:HiddenField runat="server" ID="txtStartDate_v"></asp:HiddenField>
                            <%--</div>--%>
                        </div>
                    </div>
                </div>
            </div>
            <!-- end content-module-main -->

            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #000; color: #fff; font-size: 18px; font-weight: bold; position: relative;">
                Cấu hình nội dung
            </div>
            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                <fieldset>
                    <label for="simple-input" style="font-weight: bolder; text-transform: none">
                        Chọn nội dung</label>
                    <asp:DropDownList ID="drlContent" CssClass="form-control" Style="border: 1px solid #333; border-radius: 0px;" runat="server"
                        AutoPostBack="false" onchange="templateChange()">
                    </asp:DropDownList>
                </fieldset>
            </div>
            <div class="col-md-6 col-xs-12 col-sm-6 col-lg-6" style="height: auto; padding: 10px;">
                <fieldset>

                    <label for="simple-input" style="font-weight: bolder; text-transform: none">
                        Chọn chữ ký</label>
                    <asp:DropDownList ID="drlSign" CssClass="form-control" Style="border: 1px solid #333; border-radius: 0px;" runat="server"
                        AutoPostBack="false" onchange="signatureChange()">
                    </asp:DropDownList>
                </fieldset>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 5px 5px 5px 10px;">
                <div class="col-md-2 col-lg-2 col-sm-2 col-xs-12" style="padding-left: 0px; padding-right: 5px;">
                    <asp:TextBox ID="txtWelcome" CssClass="form-control" Style="color: #333; border: 1px solid #333; border-radius: 0px; float: left;" runat="server"
                        ToolTip="Nhập lời chào cho bức thư!">Chào</asp:TextBox>

                </div>
                <div class="col-md-2 col-lg-2 col-sm-3 col-xs-12" style="padding-left: 0px; padding-top: 5px; padding-bottom: 5px; height: 34px">
                    <asp:RadioButton ID="rdoCustomerName" Checked="true" GroupName="groupWelcome" runat="server" />Tên
                                khách hàng

                </div>
                <div class="col-md-2 col-lg-2 col-sm-3 col-xs-12" style="padding-left: 0px; padding-top: 5px; padding-bottom: 5px; height: 34px">
                    <asp:RadioButton ID="rdoCustomerEmail" GroupName="groupWelcome" runat="server" />Email
                                khách hàng
                </div>
                <div class="col-md-4 col-lg-4 col-sm-3 col-xs-10" style="padding-left: 7px; padding-right: 5px;">
                    <asp:TextBox ID="txtAfterWelcome" Style="color: #333; border: 1px solid #333; border-radius: 0px;" CssClass="form-control"
                        runat="server">thân mến !</asp:TextBox>

                </div>
                <%--<asp:LinkButton ID="lbtAddWelcome" class="round button dark menu-user image-left"
                                runat="server" ToolTip="Click thêm lời chào vào nội dung"  OnClientClick="insertHello()">Thêm lời chào</asp:LinkButton>--%>

                <div class="col-md-2 col-lg-2 col-sm-1 col-xs-2" style="padding: 0px; padding-right: 7px; text-align: right;">
                    <asp:Button Style="background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px; width: 100%; min-width: 32px; min-height: 32px" OnClick="insertHello()" class="btn">
                        <span class="fa fa-plus" style="float: left; font-size: 20px"></span>
                        <span class="visible-md visible-lg">Thêm lời chào</span>
                    </asp:Button>
                </div>
            </div>
            <div style="padding: 0px 5px 0px 10px;">
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 0px 10px;">
                    <label for="simple-input" style="font-weight: bolder; text-transform: none">
                        Tiêu đề nội dung</label>
                </div>
                <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 0px; padding-right: 7px; padding-bottom: 10px;">
                    <asp:TextBox ID="txtSubject" CssClass="form-control" Style="color: #333; border: 1px solid #333; border-radius: 0px; float: left;" runat="server"
                        ToolTip="Nhập tiêu đề bức thư của bạn"></asp:TextBox>
                </div>

            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px; border: 0px solid #fff;">
                <asp:TextBox ID="txtBody" CssClass="ckeditor" Style="border-radius: 0px;" runat="server" TextMode="MultiLine"></asp:TextBox>
            </div>
            <fieldset style="width: 100%; padding: 10px;">
                <button id="Button1" runat="server" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-1" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" onserverclick="btnSendNow_Click">
                    <i style="margin-right:10px;" class="fa fa-play"></i>Gửi
                </button>
                <button id="Button2" runat="server" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-2" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" onserverclick="btnSaveAndSend_Click">
                    <i style="margin-right:10px;" class="fa fa-save"></i>Lưu và gửi
                </button>
                <button id="Button3" runat="server" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-2" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" onserverclick="btnRefesh_Click">
                    <i style="margin-right:10px;" class="fa fa-refresh"></i>Làm mới
                </button>

                <button id="btnCheck" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" type="button" value="Đánh giá nội dung" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-2" onclick="checkSpam()">
                    <i style="margin-right:10px;" class="fa fa-check"></i>Đánh giá
                </button>
                <button id="Button4" runat="server" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-2" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" onserverclick="btnPreview_Click">
                    <i style="margin-right:10px;" class="fa fa-eye"></i>Xem trước
                </button>
                <button id="Button5" runat="server" class="btn col-md-2 col-xs-6 col-sm-4 col-lg-1" style="border: 1px solid #fff; background: #333; color: #fff; text-align: center; padding: 6px 15px; border-radius: 0px;" onserverclick="btnClose_Click">
                    <i style="margin-right:10px;" class="fa fa-sign-out"></i>Ðóng
                </button>
            </fieldset>
        </div>
    </div>
    <%--<link href="../resource/css/jquery-ui.css" rel="stylesheet" type="text/css" />
    
<script type="text/javascript" src="../resource/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="../resource/js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>
<script  type="text/javascript">
    
</script>--%>
</asp:Content>
